package com.g2.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.g2.admin.model.po.AuthAuthorityPo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.g2.admin.model.po.AuthPermitUserPo;
import com.g2.admin.dao.mapper.IAuthPermitUserMapper;

import java.util.List;

@Service
@Slf4j
public class AuthPermitUserService {
    @Autowired
    private IAuthPermitUserMapper authpermituserMapper;

    public AuthPermitUserPo getAuthpermituser(long id) {
        return authpermituserMapper.selectById(id);
    }

    public void delAuthpermituser(long id) {
        authpermituserMapper.deleteById(id);
    }

    public void addAuthpermituser(AuthPermitUserPo authpermituser) {
        authpermituserMapper.insert(authpermituser);
    }

    public void updateAuthpermituser(AuthPermitUserPo authpermituser) {
        authpermituserMapper.updateById(authpermituser);
    }


    public List<Object> getAuthsByUserId(long userId) {
        return authpermituserMapper.selectObjs(new QueryWrapper<AuthPermitUserPo>().lambda()
                .select(AuthPermitUserPo::getAuthCode)
                .eq(AuthPermitUserPo::getUserId, userId));
    }
}
